program pin;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
a,b,c,d:boolean;
i, N0: integer;
x, y : double;
p1,p : real;
fin : textFile;
steps:integer;
begin
  p:=3.141592;
  a:=false;
  b:=false;
  c:=false;
  d:=false;
  randomize;
  steps:=500000000;
  for i := 1 to steps do
  begin
    x := 2*random;
    y := 2*random;
    if ((x-1)*(x-1) + (y-1)*(y-1) <= 1) then
    begin
      N0 := N0 + 1;
    end;
    p1 := N0*4/i;


      If (abs(p-p1)<0.05) and (a=false) then
        begin
          writeln(i);
          a:=true;
        end;
      If (abs(p-p1)<0.005) and (b=false) then
        begin
          writeln(i);
          b:=true;
        end;
      If (abs(p-p1)<0.0005) and (c=false) then
        begin
          writeln(i);
          c:=true;
        end;
     If (abs(p-p1)<0.00005) and (d=false) then
        begin
          writeln(i);
          d:=true;
        end;
      if(a and b and c and d)  then
        break;

  end;
  readln;

end.
